<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/15
 * Time: 14:12
 */

include_once '../tools/common.php';
include_once '../tools/DbTools.php';
$is_login = getLoginStatus();
if(!$is_login){
    echo '尚未登入，<a href="../user/loginUi.php">请登入</a>';
    die;
}else{
    $in_money = $_POST['in_money'];
    if(!empty($in_money) && $in_money>0){
        //
        session_start();
        $usreInfo = $_SESSION[$_COOKIE['Token']];
        $realName = $usreInfo['realName'];
//        $cardNum = $usreInfo['cardNum'];
//        DbTools::InitDb();
//        $sql = "update bankcard set CardMoney= CardMoney+$in_money where CardId=".$usreInfo['CardId'];
//        $result = DbTools::noSelect($sql);
//        //关闭连接
//        DbTools::close();

        //采用存钱函数
        //$result = moneyIn($usreInfo['CardId'],$in_money);
        $result = moneyInOut(1,$usreInfo['CardId'],$in_money);

        if($result['status']){
            echo '操作成功<a href="moneyIn.php">再次存钱</a>';
        }else{
            echo '操作失败: '.$result['message'];
        }
    }else{
        echo '存款金额有误！';die;
    }
}


